package com.appwoo.txtws.adapter;

import android.content.Intent;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
import android.view.ViewGroup;
import android.widget.AbsListView.LayoutParams;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TextView;
import com.appwoo.txtws.activity.BookReaderQuestionActivity;
import com.appwoo.txtws.activity.BookmarkActivity;
import com.appwoo.txtws.activity.SyncTutorialActivity;
import com.appwoo.txtws.bean.BookBean;
import java.util.ArrayList;
import java.util.Iterator;

public class SyncTutorialAdapter extends BaseAdapter
{
  private int bookCoverHeight;
  private int bookCoverWidth;
  private View.OnClickListener bookmarkOnClickListener = new View.OnClickListener()
  {
    public void onClick(View paramAnonymousView)
    {
      if (SyncTutorialAdapter.this.syncTutorial.isSubjectMenuOut())
      {
        SyncTutorialAdapter.this.syncTutorial.hiddenSubjectMenu();
        return;
      }
      BookBean localBookBean = (BookBean)paramAnonymousView.getTag();
      Intent localIntent = new Intent(SyncTutorialAdapter.this.syncTutorial, BookmarkActivity.class);
      localIntent.putExtra("bookId", localBookBean.getBookId());
      localIntent.putExtra("bookname", localBookBean.getName());
      SyncTutorialAdapter.this.syncTutorial.startActivity(localIntent);
    }
  };
  private int firstExtra;
  private int height;
  private LayoutInflater inflater;
  private View.OnClickListener layoutOnClickListener = new View.OnClickListener()
  {
    public void onClick(View paramAnonymousView)
    {
      if (SyncTutorialAdapter.this.syncTutorial.isSubjectMenuOut())
      {
        SyncTutorialAdapter.this.syncTutorial.hiddenSubjectMenu();
        return;
      }
      SyncTutorialAdapter.ViewHolderSyncTutorialListItem localViewHolderSyncTutorialListItem = (SyncTutorialAdapter.ViewHolderSyncTutorialListItem)paramAnonymousView.getTag();
      Intent localIntent = new Intent(SyncTutorialAdapter.this.syncTutorial, BookReaderQuestionActivity.class);
      localIntent.putExtra("bookname", localViewHolderSyncTutorialListItem.bookBean.getName());
      localIntent.putExtra("readerType", "local");
      SyncTutorialAdapter.this.syncTutorial.startActivity(localIntent);
    }
  };
  private View.OnLongClickListener layoutOnLongClickListener = new View.OnLongClickListener()
  {
    public boolean onLongClick(View paramAnonymousView)
    {
      SyncTutorialAdapter.ViewHolderSyncTutorialListItem localViewHolderSyncTutorialListItem = (SyncTutorialAdapter.ViewHolderSyncTutorialListItem)paramAnonymousView.getTag();
      SyncTutorialAdapter.this.syncTutorial.showLongClickDialog(localViewHolderSyncTutorialListItem.bookBean);
      return false;
    }
  };
  private ArrayList<BookBean> listData;
  private SyncTutorialActivity syncTutorial;

  public SyncTutorialAdapter(SyncTutorialActivity paramSyncTutorialActivity, ArrayList<BookBean> paramArrayList, DisplayMetrics paramDisplayMetrics, String paramString, int paramInt1, int paramInt2)
  {
    this.syncTutorial = paramSyncTutorialActivity;
    this.listData = paramArrayList;
    this.inflater = ((LayoutInflater)this.syncTutorial.getSystemService("layout_inflater"));
    this.height = paramInt1;
    this.bookCoverHeight = ((int)Math.round(0.8D * this.height));
    this.bookCoverWidth = ((int)(100.0F * (this.bookCoverHeight / 128.0F)));
    this.firstExtra = paramInt2;
  }

  private int getBookCoverDrawable(String paramString, int paramInt)
  {
    int i;
    if ("语文".equals(paramString))
      i = BookReaderQuestionActivity.book_cover_yw[paramInt];
    boolean bool;
    do
    {
      return i;
      if ("数学".equals(paramString))
        return BookReaderQuestionActivity.book_cover_sx[paramInt];
      if ("英语".equals(paramString))
        return BookReaderQuestionActivity.book_cover_yy[paramInt];
      if ("政治".equals(paramString))
        return BookReaderQuestionActivity.book_cover_zz[paramInt];
      if ("地理".equals(paramString))
        return BookReaderQuestionActivity.book_cover_dl[paramInt];
      if ("历史".equals(paramString))
        return BookReaderQuestionActivity.book_cover_ls[paramInt];
      if ("物理".equals(paramString))
        return BookReaderQuestionActivity.book_cover_wl[paramInt];
      if ("化学".equals(paramString))
        return BookReaderQuestionActivity.book_cover_hx[paramInt];
      if ("生物".equals(paramString))
        return BookReaderQuestionActivity.book_cover_sw[paramInt];
      bool = "其他".equals(paramString);
      i = 0;
    }
    while (!bool);
    return BookReaderQuestionActivity.book_cover_qt[paramInt];
  }

  public void addData(ArrayList<BookBean> paramArrayList)
  {
    if ((paramArrayList == null) || (paramArrayList.isEmpty()));
    while (true)
    {
      return;
      Iterator localIterator = paramArrayList.iterator();
      while (localIterator.hasNext())
      {
        BookBean localBookBean = (BookBean)localIterator.next();
        this.listData.add(localBookBean);
      }
    }
  }

  public int getCount()
  {
    return this.listData.size();
  }

  public Object getItem(int paramInt)
  {
    return null;
  }

  public long getItemId(int paramInt)
  {
    return 0L;
  }

  public View getView(int paramInt, View paramView, ViewGroup paramViewGroup)
  {
    ViewHolderSyncTutorialListItem localViewHolderSyncTutorialListItem;
    label155: BookBean localBookBean;
    if (paramView == null)
    {
      paramView = this.inflater.inflate(2130903210, null);
      localViewHolderSyncTutorialListItem = new ViewHolderSyncTutorialListItem(null);
      localViewHolderSyncTutorialListItem.ivBookcover = ((ImageView)paramView.findViewById(2131493544));
      localViewHolderSyncTutorialListItem.tvBookname = ((TextView)paramView.findViewById(2131493545));
      localViewHolderSyncTutorialListItem.tvBookmark = ((TextView)paramView.findViewById(2131493546));
      localViewHolderSyncTutorialListItem.layoutHavenotBook = ((LinearLayout)paramView.findViewById(2131493547));
      localViewHolderSyncTutorialListItem.ivHavenotBook = ((ImageView)paramView.findViewById(2131493548));
      localViewHolderSyncTutorialListItem.ivBookcover.setLayoutParams(new LinearLayout.LayoutParams(this.bookCoverWidth, this.bookCoverHeight));
      paramView.setTag(localViewHolderSyncTutorialListItem);
      if (localViewHolderSyncTutorialListItem != null)
      {
        if (paramInt != 0)
          break label365;
        paramView.setLayoutParams(new AbsListView.LayoutParams(-1, this.height + this.firstExtra));
        localBookBean = (BookBean)this.listData.get(paramInt);
        if (localBookBean == null)
          break label430;
        paramView.setOnClickListener(this.layoutOnClickListener);
        paramView.setOnLongClickListener(this.layoutOnLongClickListener);
        localViewHolderSyncTutorialListItem.ivBookcover.setVisibility(0);
        localViewHolderSyncTutorialListItem.tvBookname.setVisibility(0);
        localViewHolderSyncTutorialListItem.tvBookmark.setVisibility(0);
        localViewHolderSyncTutorialListItem.layoutHavenotBook.setVisibility(8);
        localViewHolderSyncTutorialListItem.ivHavenotBook.setVisibility(8);
        localViewHolderSyncTutorialListItem.bookBean = localBookBean;
        int i = paramInt % 5;
        String str = localBookBean.getSubject();
        localViewHolderSyncTutorialListItem.ivBookcover.setBackgroundResource(getBookCoverDrawable(str, i));
        localViewHolderSyncTutorialListItem.tvBookname.setText(localBookBean.getName());
        if (localBookBean.getIsRead() != 1)
          break label396;
        int j = localBookBean.getBookmarkCount();
        if (j <= 0)
          break label384;
        localViewHolderSyncTutorialListItem.tvBookmark.setOnClickListener(this.bookmarkOnClickListener);
        label317: localViewHolderSyncTutorialListItem.tvBookmark.setBackgroundResource(2130837981);
        localViewHolderSyncTutorialListItem.tvBookmark.setText(String.valueOf(j));
      }
    }
    while (true)
    {
      localViewHolderSyncTutorialListItem.tvBookmark.setTag(localBookBean);
      return paramView;
      localViewHolderSyncTutorialListItem = (ViewHolderSyncTutorialListItem)paramView.getTag();
      break;
      label365: paramView.setLayoutParams(new AbsListView.LayoutParams(-1, this.height));
      break label155;
      label384: localViewHolderSyncTutorialListItem.tvBookmark.setOnClickListener(null);
      break label317;
      label396: localViewHolderSyncTutorialListItem.tvBookmark.setText(" ");
      localViewHolderSyncTutorialListItem.tvBookmark.setBackgroundResource(2130837982);
      localViewHolderSyncTutorialListItem.tvBookmark.setOnClickListener(null);
    }
    label430: localViewHolderSyncTutorialListItem.ivBookcover.setVisibility(8);
    localViewHolderSyncTutorialListItem.tvBookname.setVisibility(8);
    localViewHolderSyncTutorialListItem.tvBookmark.setVisibility(8);
    localViewHolderSyncTutorialListItem.layoutHavenotBook.setVisibility(8);
    localViewHolderSyncTutorialListItem.ivHavenotBook.setVisibility(8);
    if (paramInt == 0)
    {
      localViewHolderSyncTutorialListItem.layoutHavenotBook.setVisibility(0);
      localViewHolderSyncTutorialListItem.ivHavenotBook.setVisibility(0);
    }
    paramView.setOnLongClickListener(null);
    paramView.setOnClickListener(null);
    localViewHolderSyncTutorialListItem.tvBookmark.setOnClickListener(null);
    return paramView;
  }

  public void setData(ArrayList<BookBean> paramArrayList)
  {
    this.listData = paramArrayList;
  }

  public void showHavenotBook()
  {
    this.listData = new ArrayList();
    for (int i = 0; ; i++)
    {
      if (i >= 5)
      {
        notifyDataSetChanged();
        return;
      }
      this.listData.add(null);
    }
  }

  private class ViewHolderSyncTutorialListItem
  {
    BookBean bookBean;
    ImageView ivBookcover;
    ImageView ivHavenotBook;
    LinearLayout layoutHavenotBook;
    TextView tvBookmark;
    TextView tvBookname;

    private ViewHolderSyncTutorialListItem()
    {
    }
  }
}

/* Location:           C:\Documents and Settings\Administrator\classes_dex2jar.jar
 * Qualified Name:     com.appwoo.txtws.adapter.SyncTutorialAdapter
 * JD-Core Version:    0.6.2
 */